package com.examples.infobox;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

/**
 * 
 * @author ryada9
 * 
 */

public class ExampleDataFilter extends ViewerFilter {

	private String searchString;

	public void setSearchText(String s) {
		// Search must be a substring of the existing value		
		this.searchString = ".*" + s + ".*";

	}

	@Override
	public boolean select(Viewer viewer, Object parentElement, Object element) {
		// TODO Auto-generated method stub
		if (searchString == null || searchString.length() == 0) {
			return true;
		}

		ExampleData data = (ExampleData) element;
		if (data.getLabel().matches(searchString)) {
			return true;
		}

		return false;
	}

}
